-
Notifications
You must be signed in to change notification settings - Fork 324
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: valid Pydantic #373
feat: valid Pydantic #373
Conversation
# set a different LLM | ||
invented_url = "https://example.com" | ||
payload = {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for writing the test
return get_setting_by_name(payload.name) | ||
|
||
def validate_presences(required: list, payload: dict): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree with the utility of a validate_presences
method, but it is not related to DB crud.
I would move it here in the factory, where schemas are defined, or in utilis in case we'll use this validation method also for plugin settings. Also infrastructure could be a place for this method, if we go for a validation set of methods
What do you think?
@@ -54,7 +54,17 @@ def upsert_embedder_setting( | |||
status_code=400, | |||
detail=f"{languageEmbedderName} not supported. Must be one of {allowed_configurations}", | |||
) | |||
|
|||
|
|||
required = EMBEDDER_SCHEMAS[languageEmbedderName]['required'] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is there always a required
key?
required = EMBEDDER_SCHEMAS[languageEmbedderName]['required'] | ||
if crud.validate_presences(required, payload): | ||
raise HTTPException( | ||
status_code=405, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's go for 400 (bad request)
|
||
# check immediate response | ||
assert response.status_code == 405 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's go for 400 (bad request)
# Conflicts: # core/cat/routes/setting/embedder_setting.py # core/cat/routes/setting/llm_setting.py # core/tests/routes/setting/test_llm_setting.py
Description
I verify that I
required
of pydantic is respected in payloads with validate_presencesRelated to issue #(cheshire-cat-ai/admin-vue#27)
Type of change
Checklist: